<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定事件</title>
</head>
<body>
<div id="app">
    <div>{{message}}</div>

    <input type="button" value="改变" @click="show1">
    <input @keydown="show2" />
    <input @mouseover="show3" />
</div>

<script src="js/vue.js"></script>
<script>
    var vue = new Vue({
        el: "#app",
        data: {
            message: "HelloWorld"
        },
        //定义方法
        methods: {
            show1() {
                this.message = "你好啊";
            },
            show2() {
                //获取按键的ascii码
                var code = event.keyCode;
                console.log("键盘被按下：" + code);
                if (code == 13) {
                    console.log("回车》执行搜索的操作");
                }
            },
            show3() {
                console.log("鼠标过来了！");
            }
        }
    });
</script>
</body>
</html>